module.exports = app => {  
    app.beforeStart(async () => {
        // 示例：启动的时候去读取 https://registry.npm.taobao.org/egg/latest 的版本信息
        console.log("sdfdsf")
    });
    app.validator.addRule('json', (rule, value) => {
        try {
            JSON.parse(value);
        } catch (err) {
            return 'must be json string';
        }
    });

    app.validator.addRule('integer', (rule, value) => {
        try {
            parseInt(value);
        } catch (err) {
            return 'must be integer';
        }
    });


    const client = app.mysql;

    client.selectToString = function* (table, options) {
        options = options || {};
        const sql = this._selectColumns(table, options.columns) +
            this._where(options.where) +
            this._orders(options.orders) +
            this._limit(options.limit, options.offset);
        return sql;
    };

    client.selectMultTable = function* () {

    }
}
